﻿using UnityEngine;
using System;
using System.Collections;

namespace Hont
{
    public static class GameTimeSpanParser
    {
        public static GameTimeSpan Parse(string str)
        {
            var day = 0;
            var hour = 0;
            var minute = 0;
            var second = 0;

            var daySplit = str.Split('.');
            var timeInfo = "";

            if (daySplit.Length > 1)
            {
                day = int.Parse(daySplit[0]);
                timeInfo = daySplit[1];
            }
            else
            {
                timeInfo = daySplit[0];
            }

            var timeSplit = timeInfo.Split(':');

            if (timeSplit.Length > 2)
                second = int.Parse(timeSplit[2]);

            if (timeSplit.Length > 1)
                minute = int.Parse(timeSplit[1]);

            if (timeSplit.Length > 0)
                hour = int.Parse(timeSplit[0]);

            return new GameTimeSpan(day, hour, minute, second);
        }
    }
}
